<template>
  <el-dialog
    title="详情"
    :close-on-click-modal="false"
    append-to-body
    :visible.sync="visible"
    class="jsbos-dialog jsbos-dialog_center"
    lock-scroll
    width="800px"
  >
    <el-row :gutter="15" class="">
      <el-form
        ref="elForm"
        :model="dataForm"
        size="small"
        label-width="100px"
        label-position="right"
      >
        <template v-if="!loading">
          <el-col :span="12">
            <el-form-item label="调查模板" prop="questionnaireName">
              <p>{{ dataForm.questionnaireName }}</p>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="问卷调查标题" prop="orderName">
              <p>{{ dataForm.orderName }}</p>
            </el-form-item>
          </el-col>
          <!-- <el-col :span="12">
            <el-form-item label="问卷调查编码" prop="orderCode">
              <p>{{ dataForm.orderCode }}</p>
            </el-form-item>
          </el-col> -->
          <el-col :span="12">
            <el-form-item label="开放类型" prop="orderType">
              <p>{{ dataForm.orderType === "internal" ? "内部" : "公开" }}</p>
            </el-form-item>
          </el-col>
          <el-col :span="24" v-if="dataForm.orderType == 'internal'">
            <el-form-item label="内部包含范围" prop="orderRange">
              <filterSelect
                width="500px"
                v-model="dataForm.orderRange"
              ></filterSelect>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="有效期开始" prop="orderStartDate">
              <p>{{ jsbos.dateFormat(dataForm.orderStartDate) }}</p>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="有效期结束" prop="orderEndDate">
              <p>{{ jsbos.dateFormat(dataForm.orderEndDate) }}</p>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="有效标志" prop="enabledMark">
              <p>
                {{ dataForm.enabledMark | dynamicText(enabledMarkOptions) }}
              </p>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="创建用户" prop="creatorUserId">
              <p>{{ dataForm.creatorUserId }}</p>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="创建时间" prop="creatorTime">
              <p>{{ dataForm.creatorTime }}</p>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="问卷调查描述" prop="description">
              <p>{{ dataForm.description }}</p>
            </el-form-item>
          </el-col>
        </template>
      </el-form>
    </el-row>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false"> 取 消</el-button>
    </span>
  </el-dialog>
</template>
<script>
import request from "@/utils/request";
export default {
  components: {},
  props: [],
  data() {
    return {
      visible: false,
      loading: false,
      printBrowseVisible: false,
      printId: "",
      dataForm: {
        id: "",
        questionnaireId: "",
        orderName: "",
        orderCode: "",
        orderRange: [],
        orderStartDate: "",
        orderEndDate: "",
        enabledMark: "1",
        description: "",
        creatorUserId: "",
        creatorTime: "",
      },
      list: [
        { type: "company", selectArr: [] },
        {
          type: "department",
          selectArr: [],
        },
        {
          type: "Role",
          selectArr: [],
        },
        {
          type: "Position",
          selectArr: [],
        },
        {
          type: "Group",
          selectArr: [],
        },
        {
          type: "user",
          selectArr: [],
        },
        {
          type: "exclude",
          selectArr: [],
        },
      ],
      enabledMarkOptions: [
        { fullName: "待生效", id: "0" },
        { fullName: "生效中", id: 10 },
        { fullName: "已过期", id: "20" },
      ],
    };
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    init(id) {
      this.dataForm.id = id || 0;
      this.visible = true;
      this.$nextTick(() => {
        this.$refs["elForm"].resetFields();
        if (this.dataForm.id) {
          this.loading = true;
          request({
            url: "/api/questionnaire/OqQuestionnaireOrder/" + this.dataForm.id,
            method: "get",
          }).then((res) => {
            this.dataInfo(res.data);
            this.loading = false;
          });
        }
      });
    },
    dataInfo(dataAll) {
      let _dataAll = dataAll;
      if (_dataAll.orderRange) {
        _dataAll.orderRange = JSON.parse(_dataAll.orderRange);
      }
      console.log("---", _dataAll.orderRange);
      if (_dataAll.orderRange.length === 0) {
        _dataAll.orderRange = this.list;
      }
      this.dataForm = _dataAll;
    },
  },
};
</script>
